public class Main {

    /**
     * 删除url的最后一个反斜杠
     *
     * @param url - URL
     * @return
     */
    public static String removeLastBackSlash(String url) {
        if (url == null || url.trim().length() == 0) {
            return url;
        }
        if (url.lastIndexOf('/') == (url.length() - 1)) {
            url = url.substring(0, url.length() - 1);
        }
        return url;
    }

    public static void main(String[] args) {
        System.out.println(removeLastBackSlash("https://d-operation-api.1meal.net/"));
        System.out.println(removeLastBackSlash("https://d-operation-api.1meal.net"));
        System.out.println(removeLastBackSlash("http://d-operation-api.1meal.net//"));
        System.out.println(removeLastBackSlash("http://sdfsf.1meal.net"));
    }

}
